package day05;

/**
 * @author Huangjin
 * @version 1.0
 * describe: 数组的演示
 * @date 2023/2/16 14:10
 */
public class ArrayDemo {
    public static void main(String[] args) {
       //4)数组的遍历：从头到尾挨个走一遍
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int)(Math.random()*100);
            System.out.print(arr[i]+"\t");
        }




        /*
        //1. 数组的定义:
        int[] a = new int[5];
        double[] d = new double[10];
        boolean[] b = new boolean[26];
        //2. 数组的初始化
        int[] arr1 = new int[3];
        int[] arr2 = {2,5,8};
        int[] arr3 = new int[]{2,5,8};
        int[] arr4;
        //arr4 = {2,5,8};//编译错误，此方式只能同时声明初始化
        arr4 = new int[]{2,5,8};
        //3)数组的访问
        int[] arr = new int[3];
        System.out.println("数组的长度："+arr.length);
        System.out.println(arr[0]);
        arr[0] = 100;
        arr[1] = 200;
        arr[2] = 300;
        //arr[3] = 400;//数组下标越界异常
        System.out.println(arr[arr.length-1]);*/

    }
}
